﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace BT1_0912367
{
    class My2DSprite
    {
        private Texture2D[] _texture;

        public Texture2D[] Texture
        {
            get { return _texture; }
            set { 
                _texture = value;
                _nTexture = _texture.Length;
                _iTexture = 0;
            }
        }
        private int _nTexture;

        public int NTexture
        {
            get { return _nTexture; }
            set { _nTexture = value; }
        }
        private int _iTexture;

        public int ITexture
        {
            get { return _iTexture; }
            set { _iTexture = value; }
        }

        private Vector2 _Position;

        public Vector2 Position
        {
            get { return _Position; }
            set { _Position = value; }
        }
        public My2DSprite(Texture2D[] textures, Vector2 position)
        {
            Texture = textures;
            Position = position;
        }

        private float _NormalDelay = 8.0f;
        public void Update(GameTime gameTime)
        {
            int delta = (int)(gameTime.ElapsedGameTime.Milliseconds/_NormalDelay);
            _iTexture = ( _iTexture +1) % _nTexture;
        }
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, float scale)
        {
           
            //spriteBatch.Draw(_texture[_iTexture], Position,null,Color.White,0.0f,new Vector2(0,0),scale,null,0);
            
            SpriteEffects s = new SpriteEffects();
            spriteBatch.Draw(_texture[_iTexture], Position,null,Color.White,0.0f, new Vector2(0,0),scale,s,0.0f);

            
        }
        public Boolean IsClick(Vector2 Mouse)
        {
            if ((Mouse.X >= Position.X) &&
                (Mouse.X <= Position.X + Texture[0].Width) &&
                (Mouse.Y >= Position.Y) &&
                (Mouse.Y <= Position.Y + Texture[0].Height))
                return true;
            return false;
        }
    }
}
